import '@tarojs/async-await'
import Taro, { Component, Config } from '@tarojs/taro'
import { Provider } from '@tarojs/redux'

import Index from './pages/home/index'

import configStore from './store'

import './app.scss'

const store = configStore()

class App extends Component {

  /**
   * 指定config的类型声明为: Taro.Config
   *
   * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
   * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
   * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
   */
  config: Config = {
    pages: [
      'pages/home/index',
      'pages/home/lists/index',
      'pages/home/apply/index',
      'pages/profile/index',
      'pages/profile/Integrals',
      'pages/profile/Winnings',
      'pages/profile/Users',
      'pages/my/index',
      'pages/activity/index',
      // 'pages/cp/GoodsUser',
      'pages/my/goods/index',
      'pages/my/goods/Launch',
      'pages/my/goods/Records',
      'pages/my/address/index',
      'pages/my/address/Profile',
      'pages/my/Questions',
      'pages/my/Feedbacks',
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: '幸运草小程序',
      navigationBarTextStyle: 'black'
    },
    tabBar: {
      // borderStyle: 'white',
      backgroundColor: '#fff',
      list: [{
        pagePath: 'pages/home/index',
        text: '首页',
        iconPath: './assets/home2x.png',
        selectedIconPath: './assets/homeActive@2x.png'
      }, {
        pagePath: 'pages/activity/index',
        text: '发起抽奖',
        iconPath: './assets/activity@2x.png',
        selectedIconPath: './assets/activityActive@2x.png'
      }, {
        pagePath: 'pages/my/index',
        text: '我的',
        iconPath: './assets/my@2x.png',
        selectedIconPath: './assets/myActive@2x.png'
      }]
    },
  }

  componentDidMount () {}

  componentDidShow () {}

  componentDidHide () {}

  componentCatchError () {}

  componentDidCatchError () {}

  // 在 App 类中的 render() 函数没有实际作用
  // 请勿修改此函数
  render () {
    return (
      <Provider store={store}>
        <Index />
      </Provider>
    )
  }
}

Taro.render(<App />, document.getElementById('app'))
